package connectFMS.sendmsg
{
	import flash.display.Sprite;
	import flash.events.NetStatusEvent;
	import flash.net.NetConnection;
	import flash.net.Responder;

	public class FMSSendMessage extends Sprite
	{
		private var nc:NetConnection;
		private var stmp:String;
		private var responeder:Responder;
		
		public function FMSSendMessage()
		{
			responeder=new Responder(responderReply);
			stmp="rtmp://localhost/sendmsg";
			initConnect(stmp);
		}
		/* comment function */
		private function initConnect(stmp:String):void
		{
			nc=new NetConnection();
			nc.client=this;
			nc.connect(stmp);
			
			nc.addEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
		}
		/* comment function */
		private function onNetStatus(event:NetStatusEvent):void
		{
			switch(event.info.code)
			{
				case "NetConnection.Connect.Success":
				{
					trace("Connect Success!");
					callFMSServer();
					break;
				}
				case "NetConnection.Connect.Rejected":
				{
					
					break;
				}
				case "NetConnection.Connect.Closed":
				{
					
					break;
				}				
			}			
		}
		/* comment function */
		private function callFMSServer():void
		{
			trace("Call to server. Please wait . . .");
			nc.call("callFromClient",responeder,"Client call Server!!!!!!!!!!!!");
		}
		/* comment function */
		private function responderReply(result:Object):void
		{
			trace("Responeder reply: "+result);
		}
	}
	/* End Class */
}